import wx

class MyFrame(wx.Frame):
    def __init__(self):
        # 创建窗体
        super().__init__(None, title = '下列列表样例', size = (600, 800))
        panel = wx.Panel(self)
        cb = wx.ComboBox(panel, choices = ['Java', 'Python', 'Ruby'])
        choice = wx.Choice(panel, choices = ['语文', '数学', '英语'])
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(cb)
        vbox.Add(choice)
        panel.SetSizer(vbox)
        # 选项切换时触发
        cb.Bind(wx.EVT_COMBOBOX, self.combobox_change)
        # 选项切换时和输入文本时都会触发
        cb.Bind(wx.EVT_TEXT, self.combobox_text)
        # 只能支持切换选项，不能输入
        choice.Bind(wx.EVT_CHOICE, self.choice_change)

    def combobox_change(self, event):
        obj = event.GetEventObject()
        print(f'选项切换，当前选中：{obj.GetValue()}')

    def combobox_text(self, event):
        obj = event.GetEventObject()
        print(f'选框文本已改变，当前：{obj.GetValue()}')

    def choice_change(self, event):
        obj = event.GetEventObject()
        print(f'选项切换，当前选中：{obj.GetStringSelection()}')

app = wx.App()
window = MyFrame()
window.Show()
app.MainLoop()